﻿Imports Sistema_InformacionNaviera.BC
Imports Sistema_InformacionNaviera.BE
Imports Sistema_InformacionNavier.UTIL


Public Class Consultar_Desglose_2

    'Inherits System.Web.UI.Page
    Inherits PaginaBase

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then
            'txtNave.Text = "" : txtPto.Text = "" : txtNroBl.Text = "" : lblKvje.Text = 0
            CargarGridConsulta()

        End If
        If My.Request.Params("__EVENTTARGET") = "MiFuncionPaquetes" Then
            CargarDatosViajePopUp()
        End If


    End Sub

    Public Sub CargarDatosViajePopUp()

        If Session("BPCodViaje") = Nothing Then
            txtNave.Text = String.Empty
            'txtDescripcionNave.Text = String.Empty
        Else
            txtNave.Text = Session("BPCodViaje")
            'txtDescripcionNave.Text = Session("BPDesViaje")
        End If
    End Sub


    Public Sub CargarGridConsulta()
        Dim objBlImpoBE As New BillOfLadingImpoBE
        Dim lstBlImpoBE As New List(Of BillOfLadingImpoBE)
        Dim objUtil As New Funciones
        Dim objBlImpoBC As New BillOfLadingImpoBC

        objBlImpoBE.KVJE = If(txtNave.Text = String.Empty, 0, CType(txtNave.Text, Integer))
        objBlImpoBE.Ptoo = ""
        objBlImpoBE.Nume = txtNroBl.Text.Trim

        Dim dt As DataTable = Nothing
        Dim sMensaje As String = ""



        lstBlImpoBE = objBlImpoBC.ListarBlImpo(objBlImpoBE, dt, sMensaje)
        dgBlImportacion.DataSource = lstBlImpoBE
        dgBlImportacion.DataBind()
    End Sub

    Private Sub dgBlImportacion_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles dgBlImportacion.RowCommand

        Dim sCadenaBL As String = Convert.ToString(e.CommandArgument)
        Dim iKvje As Integer
        Dim iKbli As Integer

        iKvje = sCadenaBL.Substring(0, InStr(sCadenaBL, "|") - 1)
        iKbli = sCadenaBL.Substring(InStr(sCadenaBL, "|"), Len(sCadenaBL) - InStr(sCadenaBL, "|"))


        Session("Desglose_iKvje") = iKvje
        Session("Desglose_iKbli") = iKbli

        '----------------------------------------------------------------------------------

        Select Case e.CommandName  '.ToLower
            Case "Desglose"
                Response.Redirect("GestionarDesglose.aspx", True)
        End Select

    End Sub


    Protected Sub btnConsultar1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnConsultar1.Click


        CargarGridConsulta()

    End Sub


    Sub Cambiarpagina(ByVal sender As Object, ByVal e As GridViewPageEventArgs)

        Dim objBlImpoBE As New BillOfLadingImpoBE
        Dim lstBlImpoBE As New List(Of BillOfLadingImpoBE)
        Dim objUtil As New Funciones
        Dim objBlImpoBC As New BillOfLadingImpoBC

        objBlImpoBE.KVJE = If(txtNave.Text = String.Empty, 0, CType(txtNave.Text, Integer))
        objBlImpoBE.Ptoo = ""
        objBlImpoBE.Nume = txtNroBl.Text.Trim

        Dim dt As DataTable = Nothing
        Dim sMensaje As String = ""

        lstBlImpoBE = objBlImpoBC.ListarBlImpo(objBlImpoBE, dt, sMensaje)
        dgBlImportacion.PageIndex = e.NewPageIndex
        dgBlImportacion.DataSource = lstBlImpoBE
        dgBlImportacion.DataBind()


    End Sub


    Protected Sub btnSalir_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSalir.Click

    End Sub
End Class